package com.dq.Week3.day12.linkedList;

import java.util.Iterator;
import java.util.LinkedList;

public class StackDemo02 {
    public static void main(String[] args) {
        String s = "1+((a+b)/c)+5/(2+a)";
        boolean flag = testXkh(s);
        System.out.println(flag);
    }

    private static boolean testXkh(String s){
      LinkedList<Character> list = new LinkedList<>();

      char[] charArray = s.toCharArray();
        for (int i = 0; i < charArray.length; i++) {
            if(charArray[i]=='(')
            {
                list.push('(');
            }
            if(charArray[i]==')')
            {
                try {
                list.pop();
            }
            catch (Exception e)
            {
                System.out.println("已完全排除，没有其他元素在栈内");
                return false;
            }

            }
        }
        return list.size()==0;
    }
}
